<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>bind⽅法实验</title>
</head>

<body>
    <script>
        function foo(name, age, height, address) {
            console.log("foo:", this);
            console.log("参数:", name, age, height, address);
        }
        var obj = { name: "gkd" };
        // bind基本使⽤
        var bar = foo.bind(obj);
        bar(); // this -> obj
        // bind使⽤并传⼊参数
        var barWithArgs = foo.bind(obj, "kobe", 18, 1.88);
        barWithArgs("james"); // 仅“james”作为额外参数传⼊
    </script>
</body>

</html>